//package com.pony.iphone.mq;
//
//import com.pony.iphone.config.QuestionQueueConfig;
//import com.pony.iphone.dto.QuestionMessage;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import java.util.List;
//
///**
// * 消息生产者
// * @author pony
// * @create 2025-11-06 16:57
// */
//@Component
//@Slf4j
//public class QuestionMessageProducer {
//
//    @Autowired
//    private RabbitTemplate rabbitTemplate;
//
//    @Autowired
//    private QuestionDeduplicationService deduplicationService;
//
//    public boolean sendQuestion(QuestionMessage message) {
//        // 先去重检查
//        if (deduplicationService.isDuplicate(message)) {
//            log.info("题目重复，不发送到队列: {}", message.getQuestionContent());
//            return false;
//        }
//
//        try {
//            rabbitTemplate.convertAndSend(
//                QuestionQueueConfig.QUESTION_EXCHANGE,
//                QuestionQueueConfig.QUESTION_ROUTING_KEY,
//                message
//            );
//            log.info("新题目已发送到队列: {}", message.getQuestionContent());
//            return true;
//        } catch (Exception e) {
//            log.error("发送题目到队列失败: {}", message, e);
//            return false;
//        }
//    }
//
//    public boolean sendQuestion(String question, List<String> options, String libraryName) {
//        return sendQuestion(new QuestionMessage(question, options, libraryName));
//    }
//}